package com.mycase.im.boot.controller;

import com.mycase.im.boot.entity.communication.ResponseMessage;
import com.mycase.im.boot.entity.database.ImCircle;
import com.mycase.im.boot.service.CircleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * @Author ZhuHJay
 * @Date 2021/9/16 16:59
 */
@RestController
@RequestMapping("/api/circle")
public class CircleController {

    @Autowired
    private CircleService circleService;

    @PostMapping("/publish")
    public ResponseMessage publishDynamic(@Valid ImCircle imCircle){
        if( !circleService.save(imCircle) ){
            return ResponseMessage.error("发布失败请重试");
        }
        return ResponseMessage.success().appendData("id", imCircle.getId());
    }



}
